﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace yaTDL.Core
{
    public class Change: NotifyObject
    {

        #region Fields

        DateTime _changeTime;
        Type _changedItemType;
        string _itemId;
        ChangeKind _kind;
        string _propertyName;
        bool _handledInSync;

        #endregion


        #region Properties


        public DateTime ChangeTime 
        {
            get
            { return _changeTime; }
            set
            {
                if (value != _changeTime)
                {
                    _changeTime = value;
                    RaisePropertyChanged("ChangeTime");
                }
            }
        }

        public Type ChangedItemType 
        {
            get { return _changedItemType; }
            set
            {
                if (value != _changedItemType)
                {
                    _changedItemType = value;
                    RaisePropertyChanged("ChangedItemType");
                }
            }
        }

        public String ItemId 
        {
            get { return _itemId; }
            set
            {
                if (value != _itemId)
                {
                    _itemId = value;
                    RaisePropertyChanged("ItemId");
                }
            }
        }

        public ChangeKind Kind 
        {
            get { return _kind; }
            set
            {
                if (value != _kind)
                {
                    _kind = value;
                    RaisePropertyChanged("Kind");
                }
            }
        }

        public string PropertyName 
        {
            get { return _propertyName; }
            set
            {
                if (value != _propertyName)
                {
                    _propertyName = value;
                    RaisePropertyChanged("PropertyName");
                }
            }
        }

        public bool HandledInSync 
        {
            get { return _handledInSync; }
            set
            {
                if (value != _handledInSync)
                {
                    _handledInSync = value;
                    RaisePropertyChanged("HandledInSync");
                }
            }
        }


        #endregion


        public Change()
        {
            HandledInSync = false;
        }
    }

    public enum ChangeKind
    {
        Added,
        Deleted,
        Modified,
        Unspecified
    }

    public struct PropertyChange
    {
        public string PropertyName { get; set; }
        public object Value1 { get; set; }
        public object Value2 { get; set; }
    }
}
